﻿using System.Linq;
using Daemon.Common;
using Daemon.Common.Helpers;
using Daemon.Infrustructure.EF;
using Daemon.Repository.EF.Enums;
using Daemon.Repository.Contract;
using Daemon.Model;
using System;
using System.Linq.Expressions;
using System.Collections.Generic;

namespace Daemon.Repository.EF
{
	public class TakeAwayUserCouponRepository : Repository<TakeAwayUserCoupon>, ITakeAwayUserCouponRepository
	{
		protected override Expression<Func<TakeAwayUserCoupon, int>> PrimaryKeyExpression => r => r.Id;

		public TakeAwayUserCouponRepository(ApiDBContent context) : base(context)
		{
		}

		protected override IEnumerable<TakeAwayUserCoupon> IncludeRelationships(IEnumerable<TakeAwayUserCoupon> entities, ApiDBContent db)
		{
			return base.IncludeRelationships(entities, db);
		}

		private void SetCouponInfo(IEnumerable<TakeAwayUserCoupon> entities)
		{
			if (!RouteParameterHelper.CheckRouteParameter(RelationshipNames, TakeAwayUserCouponRelationShipEnum.CouponInfo))
			{
				return;
			}

			var couponIds = entities.Select(r => r.Id).ToList();
			var dicCoupon = Context.TakeAwayCoupon.Where(r => couponIds.Contains(r.Id)).ToList().GroupBy(r => r.Id).ToDictionary(r => r.Key, r => r.Select(coupon =>
			{
				return new CouponInfo()
				{

				};
			}));
		}
	}
}
